package com.xyht.sca_s.student_manage_system.modules.appDynamic.controller;

import com.xyht.sca_s.student_manage_system.common.commonReturn.ResponseResult;
import com.xyht.sca_s.student_manage_system.common.desEncodeAndDecode.annotation.SecretBody;
import com.xyht.sca_s.student_manage_system.modules.appDynamic.entity.req.AddBranchReq;
import com.xyht.sca_s.student_manage_system.modules.appDynamic.entity.req.AppProcessNodeConfigReq;
import com.xyht.sca_s.student_manage_system.modules.appDynamic.entity.req.ConditionNodeInfoReq;
import com.xyht.sca_s.student_manage_system.modules.appDynamic.entity.req.ProcessNodeIdReq;
import com.xyht.sca_s.student_manage_system.modules.appDynamic.service.AppProcessNodeConfigService;
import io.swagger.annotations.ApiModelProperty;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 * 流程节点配置表 前端控制器
 * </p>
 *
 * @author XYHT
 * @since 2023-07-26
 */
@RestController
@RequestMapping("/processNodeConfig")
@SecretBody
public class AppProcessNodeConfigController {
    @Resource
    private AppProcessNodeConfigService appProcessNodeConfigService;

    @ApiModelProperty(value = "展示流程节点")
    @GetMapping("/nodeConfigList")
    public ResponseResult nodeConfigList(@RequestParam String appId) {
        return appProcessNodeConfigService.nodeConfigList(appId);
    }

    @ApiModelProperty(value = "展示条件节点")
    @GetMapping("/conditionNodeConfigList")
    public ResponseResult conditionNodeConfigList(@RequestParam String id) {
        return appProcessNodeConfigService.conditionNodeConfigList(id);
    }

    @ApiModelProperty(value = "保存条件节点")
    @PostMapping("/saveConditionNode")
    public ResponseResult saveConditionNode(@RequestBody ConditionNodeInfoReq conditionNodeInfoReq) {
        return appProcessNodeConfigService.saveConditionNode(conditionNodeInfoReq);
    }

    @ApiModelProperty(value = "添加流程节点")
    @PostMapping("/addProcessNode")
    public ResponseResult addProcessNode(@RequestBody AppProcessNodeConfigReq processNodeConfigReq) {
        return appProcessNodeConfigService.addProcessNode(processNodeConfigReq);
    }

    @ApiModelProperty(value = "添加条件分支")
    @PostMapping("/addBranch")
    public ResponseResult addBranch(@RequestBody AddBranchReq addBranchReq) {
        return appProcessNodeConfigService.addBranch(addBranchReq);
    }

    @ApiModelProperty(value = "添加条件")
    @PostMapping("/addCondition")
    public ResponseResult addCondition(@RequestBody ProcessNodeIdReq nodeIdReq) {
        return appProcessNodeConfigService.addCondition(nodeIdReq);
    }

    @ApiModelProperty(value = "删除流程节点")
    @PostMapping("/deleteProcessNode")
    public ResponseResult deleteProcessNode(@RequestBody ProcessNodeIdReq nodeIdReq) {
        return appProcessNodeConfigService.deleteProcessNode(nodeIdReq);
    }

    @ApiModelProperty(value = "删除条件节点")
    @PostMapping("/deleteConditionNode")
    public ResponseResult deleteConditionNode(@RequestBody ProcessNodeIdReq nodeIdReq) {
        return appProcessNodeConfigService.deleteConditionNode(nodeIdReq);
    }

    @ApiModelProperty(value = "修改流程节点")
    @PostMapping("/editProcessNode")
    public ResponseResult editProcessNode(@RequestBody AppProcessNodeConfigReq processNodeConfigReq) {
        return appProcessNodeConfigService.editProcessNode(processNodeConfigReq);
    }
}

